//
//  StudioHeadCollectionViewCell.m
//  Arts1
//
//  Created by 孤星晨宇 on 15/9/21.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "StudioHeadCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#import "AllHeader.h"

@implementation StudioHeadCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if ( self) {
        _backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)];
        _backgroundImageView.layer.cornerRadius = 4;
        _backgroundImageView.layer.masksToBounds = YES;
        _backgroundImageView.backgroundColor = kRandomColor;
        [_backgroundImageView setContentMode:(UIViewContentModeScaleAspectFill)];
        [self.contentView addSubview:_backgroundImageView];
        
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(_backgroundImageView.width / 2 - 28, _backgroundImageView.height /2.0 - 7, 56, 14)];
        _nameLabel.font = [UIFont systemFontOfSize:14];
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.text = @"九大美院";
        [self.contentView addSubview:_nameLabel];
        
    }
    return  self;
}

- (void)setArea:(AreaModel *)area{
    _area = area ;
    if (_area.backImg) {
        [_backgroundImageView sd_setImageWithURL:[NSURL URLWithString:_area.backImg]  placeholderImage:nil options:(SDWebImageRetryFailed | SDWebImageLowPriority) completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
            UIImage *bImage = [image boxblurImageWithBlur:0.75];
            _backgroundImageView.image = bImage;

        }];
    } else {
        UIImage *mImage = [UIImage imageNamed:@"GoodStudio"];
        _backgroundImageView.image = [mImage boxblurImageWithBlur:0.75];
    }
    _nameLabel.text = _area.place;
}



@end
